define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'echarts', 'echarts-theme',], function ($, undefined, Backend, Table, Form, Echarts, undefined) {

    var Controller = {
        index: function () {
            var companyinfo= Config.companyinfo;
            if(companyinfo==1){
                var url='kupay/compay';
                Backend.api.addtabs(url);
            }
            $(".seelogs").click(function(){
                var url='kupay/setlog';
                Backend.api.addtabs(url);
            })
            $('.setting').click(function () {
                //获取选中的条目ID集合
                var url = 'kupay/paylog/type';//弹出窗口 add.html页面的（fastadmin封装layer模态框将以iframe的方式将add输出到index页面的模态框里）
                Fast.api.open(url, "提示", {
                    callback: function (value) {
                        location.reload();
                    },success:function(){
                    }
                });
            }),
                $(".ipt").click(function () {
                    var chk_value = [];//定义一个数组
                    $('input[class="ipt"]:checked').each(function () {//遍历每一个名字为nodes的复选框，其中选中的执行函数
                        chk_value.push($(this).val());//将选中的值添加到数组chk_value中
                    });
                    var groups = chk_value.join(",");

                    if (groups.includes('1')) {
                        $(".weixn").show();
                    } else {
                        $(".weixn").hide();
                    }
                    if (chk_value.length > 0) {
                        $("#btn-myimport-file").attr("disabled", false);
                    } else {
                        $("#btn-myimport-file").attr("disabled", true);
                    }
                    $("#save_send").val(groups);

                }),
                $("#btn-myimport-file").data("upload-success", function (data) {
                    $("#save_type").val($("#c-pid").val());

                    if($("#c-pid").val()==null){
                        layer.msg('请选择发薪类型');return;
                    }
                    $("#save_time").val($("#c-timingtime").val());
                    Fast.api.ajax({
                        url: 'kupay/paylog/import',
                        data: {file: data.url},
                    }, function (data, ret) {
                        $(".zhanshi").hide();
                        $("#table-list").show()
                        $("#imgs1").attr('src', '/assets/addons/kupay/img/wancheng.png')
                        $("#imgs2").attr('src', '/assets/addons/kupay/img/bar2_2.png')
                        var bar = ret.data.tags;
                        var info = ret.data.info;
                        var html = '';
                        bar.forEach(function (element) {
                            html += '<td>' + element + '</td>'
                        });
                        $("#content-bar").append(html)
                        var htmls = '';
                        for (var i = 0; i < info.length; i++) {
                            htmls += '<tr>'
                            bar.forEach(function (element) {
                                htmls += '<td>' + info[i][element] + '</td>'
                            });
                            htmls += '</tr>'

                        }
                        $("#table").append(htmls)
                        var html = '';
                        bar.forEach(function (element) {
                            if (element.includes('姓名')) {
                                html += '<option selected="selected" value=' + element + '>' + element + '</option>'
                            } else {
                                html += '<option value=' + element + '>' + element + '</option>'
                            }

                        });
                        $("#others-name").append(html)
                        var html = '';
                        bar.forEach(function (element) {
                            if (element.includes('手机')) {
                                html += '<option selected="selected" value=' + element + '>' + element + '</option>'
                            } else {
                                html += '<option value=' + element + '>' + element + '</option>'
                            }

                        });
                        $("#others-phone").append(html)

                        var html = '';
                        bar.forEach(function (element) {
                            if (element.includes('邮箱')) {
                                html += '<option selected="selected" value=' + element + '>' + element + '</option>'
                            } else {
                                html += '<option value=' + element + '>' + element + '</option>'
                            }

                        });
                        $("#others-email").append(html)
                        var html = '<option value=""></option>';
                        bar.forEach(function (element) {
                            html += '<option value=' + element + '>' + element + '</option>'

                        });
                        $("#others-price").append(html)
                        $(".content-title-num").text(info.length)
                    });
                });
            $(".next").click(function () {
                var name = $("#others-name").val();
                var phone = $("#others-phone").val();
                var price = $("#others-price").val();
                if (name == '' || name == 'null') {
                    layer.msg('请匹配员工姓名！');
                    return;
                } else if (phone == '' || phone == 'null') {
                    layer.msg('请匹配手机！');
                    return;
                }
                if (phone.includes('手机') || phone == '电话') {

                } else {
                    layer.msg('所选列手机号均不正确，请重新选择！');
                    return;
                }
                if (price == '' || price == 'null') {
                    layer.msg('请匹配实发工资！');
                    return;
                }
                $("#save_name").val(name);
                $("#save_phone").val(phone);
                $("#save_price").val(price);
                $("#save_email").val($("#others-email").val());
                $(".zhanshi").hide();
                $("#shows").css('display', 'flex')
                $("#imgs2").attr('src', '/assets/addons/kupay/img/wancheng.png')
                $("#imgs3").attr('src', '/assets/addons/kupay/img/bar3_2.png')
                var times = $("#save_time").val();
                times = times.split('-')
                var year = times[0]
                times = times[1] * 10 / 10;
                $("#xintime").text(times + '月-' + $("#save_type").val());
                $(".tantimes").text(year + '年' + times + '月');
                $.ajax({
                    type: 'POST',
                    url: "kupay/paylog/infos",
                    data: [],
                    success: function (info) {
                        if (info.code == 1) {
                            var info = info.msg;
                            var tags = info.data;
                            $("#shiji").text(info[price]);
                            info = Object.entries(info)
                            var html = '';
                            info.forEach(function (element, index) {
                                if (element[1] != '') {
                                    html += '  <div class="company-info-item"style="justify-content: space-between;">'
                                        + '<div class="tip4">' + element[0] + '</div>'
                                        + '<div class="tip4">' + element[1] + '</div>'
                                        + '</div>'
                                }

                            });
                            var htmls = '';
                            info.forEach(function (element, index) {
                                if (element[1] != '') {
                                    htmls += '  <option value="' + element[0] + '">' + element[0] + '</option>'
                                }

                            });
                            $("#c-flag").append(htmls)
                            $("#c-flag").selectpicker('refresh')
                            $("#preview_body").append(html)
                        } else {
                            location.reload();
                        }

                    }
                });
            }),
                $("#c-switch1_1").click(function () {
                    var val = $('#c-switch1').val();
                    if (val == 0) {
                        //开
                        var inns = $(".el-textarea__inner").val()
                        $("#announcement").text(inns)
                        $(".announcement").show()
                        $(".el-textarea").show()
                    } else {
                        //关
                        $(".el-textarea").hide()
                        $(".announcement").hide()
                    }
                })
            $("#c-switch_1").click(function () {
                var val = $('#c-switch').val();
                var selected = $("#c-flag").val();
                if (val == 0) {
                    //开
                    $.ajax({
                        type: 'POST',
                        url: "kupay/paylog/infos",
                        data: [],
                        success: function (info) {
                            if (info.code == 1) {
                                var info = info.msg;
                                info = Object.entries(info)
                                var list = [];
                                if (selected != null) {
                                    selected.join(',')
                                    for (var i = 0; i < info.length; i++) {
                                        if (selected.includes(info[i][0])) {
                                        } else {
                                            list.push(info[i]);
                                        }
                                    }
                                    var html = '';
                                    list.forEach(function (element, index) {
                                        html += '  <div class="company-info-item"style="justify-content: space-between;">'
                                            + '<div class="tip4">' + element[0] + '</div>'
                                            + '<div class="tip4">' + element[1] + '</div>'
                                            + '</div>'

                                    });
                                    $("#preview_body .company-info-item").remove()
                                    $("#preview_body").append(html)
                                } else {
                                    var html = '';
                                    info.forEach(function (element, index) {
                                        html += '  <div class="company-info-item"style="justify-content: space-between;">'
                                            + '<div class="tip4">' + element[0] + '</div>'
                                            + '<div class="tip4">' + element[1] + '</div>'
                                            + '</div>'

                                    });
                                    $("#preview_body .company-info-item").remove()
                                    $("#preview_body").append(html)
                                }

                            } else {
                                location.reload();
                            }

                        }
                    });
                } else {
                    //关
                    $.ajax({
                        type: 'POST',
                        url: "kupay/paylog/infos",
                        data: [],
                        success: function (info) {
                            if (info.code == 1) {
                                var info = info.msg;
                                info = Object.entries(info)
                                var list = [];
                                if (selected != null) {
                                    for (var i = 0; i < info.length; i++) {
                                        if (selected.includes(info[i][0])) {
                                        } else {
                                            list.push(info[i]);
                                        }
                                    }
                                    var html = '';
                                    list.forEach(function (element, index) {
                                        if (element[1] != '') {
                                            html += '  <div class="company-info-item"style="justify-content: space-between;">'
                                                + '<div class="tip4">' + element[0] + '</div>'
                                                + '<div class="tip4">' + element[1] + '</div>'
                                                + '</div>'
                                        }

                                    });
                                    $("#preview_body .company-info-item").remove()
                                    $("#preview_body").append(html)
                                } else {
                                    var html = '';
                                    info.forEach(function (element, index) {
                                        if (element[1] != '') {
                                            html += '  <div class="company-info-item"style="justify-content: space-between;">'
                                                + '<div class="tip4">' + element[0] + '</div>'
                                                + '<div class="tip4">' + element[1] + '</div>'
                                                + '</div>'
                                        }

                                    });
                                    $("#preview_body .company-info-item").remove()
                                    $("#preview_body").append(html)
                                }

                            } else {
                                location.reload();
                            }

                        }
                    });
                }
            })
            $("#c-switch2_1").click(function () {
                var val = $('#c-switch2').val();
                if (val == 0) {
                    //开

                    $("#sendtimes").show()
                } else {
                    //关
                    $("#sendtimes").hide()
                }
            })
            $("#c-flag").change(function () {
                var selected = $(this).val();

                var val = $('#c-switch').val();
                if (val == 1) {
                    //开
                    $.ajax({
                        type: 'POST',
                        url: "kupay/paylog/infos",
                        data: [],
                        success: function (info) {
                            if (info.code == 1) {
                                var info = info.msg;
                                info = Object.entries(info)
                                if (selected != null) {

                                    selected.join(',')
                                    var list = [];
                                    for (var i = 0; i < info.length; i++) {
                                        if (selected.includes(info[i][0])) {
                                        } else {
                                            list.push(info[i]);
                                        }
                                    }
                                    var html = '';
                                    list.forEach(function (element, index) {
                                        html += '  <div class="company-info-item"style="justify-content: space-between;">'
                                            + '<div class="tip4">' + element[0] + '</div>'
                                            + '<div class="tip4">' + element[1] + '</div>'
                                            + '</div>'
                                    });
                                    $("#preview_body .company-info-item").remove()
                                    $("#preview_body").append(html)
                                } else {
                                    var html = '';
                                    info.forEach(function (element, index) {
                                        html += '  <div class="company-info-item"style="justify-content: space-between;">'
                                            + '<div class="tip4">' + element[0] + '</div>'
                                            + '<div class="tip4">' + element[1] + '</div>'
                                            + '</div>'
                                    });
                                    $("#preview_body .company-info-item").remove()
                                    $("#preview_body").append(html)
                                }
                            } else {
                                location.reload();
                            }

                        }
                    });
                } else {
                    //关
                    $.ajax({
                        type: 'POST',
                        url: "kupay/paylog/infos",
                        data: [],
                        success: function (info) {
                            if (info.code == 1) {
                                var info = info.msg;
                                info = Object.entries(info)
                                if (selected != null) {
                                    selected.join(',')
                                    var list = [];
                                    for (var i = 0; i < info.length; i++) {
                                        if (selected.includes(info[i][0])) {
                                        } else {
                                            list.push(info[i]);
                                        }
                                    }
                                    var html = '';
                                    list.forEach(function (element, index) {
                                        if (element[1] != '') {
                                            html += '  <div class="company-info-item"style="justify-content: space-between;">'
                                                + '<div class="tip4">' + element[0] + '</div>'
                                                + '<div class="tip4">' + element[1] + '</div>'
                                                + '</div>'
                                        }

                                    });
                                    $("#preview_body .company-info-item").remove()
                                    $("#preview_body").append(html)
                                } else {
                                    var html = '';
                                    info.forEach(function (element, index) {
                                        if (element[1] != '') {
                                            html += '  <div class="company-info-item"style="justify-content: space-between;">'
                                                + '<div class="tip4">' + element[0] + '</div>'
                                                + '<div class="tip4">' + element[1] + '</div>'
                                                + '</div>'
                                        }

                                    });
                                    $("#preview_body .company-info-item").remove()
                                    $("#preview_body").append(html)
                                }

                            } else {
                                location.reload();
                            }

                        }
                    });
                }

            })

            $(".el-textarea__inner").bind('input porpertychange', function () {
                var inns = $(".el-textarea__inner").val()
                $("#announcement").text(inns)
            });
            $("#back").click(function () {
                $(".zhanshi").hide();
                $("#table-list").show()
                $("#imgs1").attr('src', '/assets/addons/kupay/img/wancheng.png')
                $("#imgs2").attr('src', '/assets/addons/kupay/img/bar2_2.png')
                $("#imgs3").attr('src', '/assets/addons/kupay/img/bar3_1.png')
            })
            $("#sendout").click(function () {
                $("#tishik").show()
            })

            $(".quxias").click(function () {
                $("#tishik").hide()
            })
            $("#qurest").click(function () {
                var name = $("#save_name").val();
                var phone = $("#save_phone").val();
                var price = $("#save_price").val();
                var type = $("#save_type").val();
                var email = $("#save_email").val();
                var time = $("#save_time").val();
                var sends = $("#save_send").val();
                var val = $('#c-switch').val();
                var val1 = $('#c-switch1').val();
                var val2 = $('#c-switch2').val();

                var selected, gongao, dingshi, kongzhi, shifa
                selected = $("#c-flag").val();
                shifa = $("#shiji").text();
                if (val == 1) {
                    kongzhi = 1;
                } else {
                    kongzhi = 0;
                }
                if (val1 == 1) {
                    gongao = $(".el-textarea__inner").val();
                } else {
                    gongao = '';
                }
                if (val2 == 1) {
                    dingshi = $("#c-date").val() + ' ' + $("#c-time").val() + ':00';
                } else {
                    dingshi = '';
                }
                layer.msg('正在保存数据', {time: 0, icon:16});
                $.ajax({
                    type: 'POST',
                    url: "kupay/paylog/sendsave",
                    data: {
                        name: name,
                        phone: phone,
                        time: time,
                        price: price,
                        type: type,
                        email: email,
                        sends: sends,
                        selected: selected,
                        gongao: gongao,
                        dingshi: dingshi,
                        kongzhi: kongzhi,
                        shifa: shifa
                    },
                    success: function (info) {
                        layer.close();
                        var listnum=0;//总条数
                        var sus=0;//成功
                        var ers=0;//失败
                        var pages=1;
                        if (info.code == 1) {
                            $("#tishik").hide()
                            $(".zhanshi").hide();
                            $("#results").show()
                            $("#imgs3").attr('src', '/assets/addons/kupay/img/wancheng.png')
                            $("#imgs4").attr('src', '/assets/addons/kupay/img/bar4_2.png')

                            function sends(){
                                var pagesnum=Math.ceil(listnum/10);
                                var m=(pages-1)*10+1;
                                var n=10*pages
                                if(n>listnum){
                                    n=listnum;
                                }
                                layer.msg('正在发送第'+m+'到'+n+'条', {time: 0, icon:16});
                                //发信息
                                $.ajax({
                                    type: 'POST',
                                    url: "kupay/paylog/sends",
                                    data: {id: info.msg,page:pages,limit:10},
                                    success: function (info) {
                                        pages=pages+1;
                                        sus=sus+info.msg;
                                        ers=ers+info.data;
                                        if(pages<=pagesnum){
                                            sends();
                                        } else{
                                            layer.closeAll();
                                            //发信息
                                            $("#sendsnum2").text(sus)
                                            $("#sendsnum3").text(ers)
                                            $("#sendsin").css('display', 'none')
                                            $("#sendsin4").hide();
                                            $("#sendsout").css('display', 'flex')
                                        }
                                    }
                                });

                            }

                            if (info.data.dingshi == 1) {

                                $("#sendsout").hide();
                                $("#sendsin4").hide();
                                $("#sendsnum1").text(info.data.num)
                                $("#sendsin").css('display', 'flex');
                                listnum=info.data.num;
                                sends();



                            } else {
                                $("#sendsnum4").text(info.data.num)
                                $("#sendsnum5").text(info.data.dingshi)
                                $("#sendsin").hide();
                                $("#sendsout").hide();
                                $("#sendsin4").css('display', 'flex');
                                layer.closeAll();
                            }


                        } else {
                            layer.msg(info.msg)
                        }

                    }
                });
            })
            $(".chongxin").click(function () {
                location.reload();
            })

            Controller.api.bindevent();
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        info: function () {

            Controller.api.bindevent();
        },
        shows: function () {

            var myChart = Echarts.init(document.getElementById('echart'), 'walden');

            // 指定图表的配置项和数据
            var option = {
                title: {
                    text: '',
                    subtext: ''
                },
                color: [
                    "#18d1b1",
                    "#3fb1e3",
                    "#626c91",
                    "#a0a7e6",
                    "#c4ebad",
                    "#96dee8"
                ],
                tooltip: {
                    trigger: 'axis'
                },
                legend: {
                    data: [__('Register user')]
                },
                toolbox: {
                    show: false,
                    feature: {
                        magicType: {show: true, type: ['stack', 'tiled']},
                        saveAsImage: {show: true}
                    }
                },
                xAxis: {
                    type: 'category',
                    boundaryGap: false,
                    data:  Config.times
                },
                yAxis: {},
                grid: [{
                    left: 'left',
                    top: 'top',
                    right: '10',
                    bottom: 30
                }],
                series: [{
                    name:'员工数量',
                    type: 'line',
                    smooth: true,
                    areaStyle: {
                        normal: {}
                    },
                    lineStyle: {
                        normal: {
                            width: 1.5
                        }
                    },
                    data:   Config.datas,
                }]
            };

            // 使用刚指定的配置项和数据显示图表。
            myChart.setOption(option);
            var companyinfo= Config.companyinfo;
            if(companyinfo==1){
                var url='kupay/compay';
                Backend.api.addtabs(url);
            }
            $("#types-btn1").click(function(){
                var types=$(this).data('info');
                $("#types").val(types)
                var type=$("#c-pid").val()
                $("#types-btn2").addClass('com-button')
                $("#types-btn2").removeClass('com-button-click')
                $("#types-btn1").removeClass('com-button')
                $("#types-btn1").addClass('com-button-click')
                $.ajax({
                    type: 'POST',
                    url: "kupay/paylog/showtypman",
                    data: {type:type},
                    success: function (info) {
                        if (info.code == 1) {
                            var datas=info.msg
                            var myChart = Echarts.init(document.getElementById('echart'), 'walden');

                            // 指定图表的配置项和数据
                            var option = {
                                title: {
                                    text: '',
                                    subtext: ''
                                },
                                color: [
                                    "#18d1b1",
                                    "#3fb1e3",
                                    "#626c91",
                                    "#a0a7e6",
                                    "#c4ebad",
                                    "#96dee8"
                                ],
                                tooltip: {
                                    trigger: 'axis'
                                },
                                legend: {
                                    data: '员工数量'
                                },
                                toolbox: {
                                    show: false,
                                    feature: {
                                        magicType: {show: true, type: ['stack', 'tiled']},
                                        saveAsImage: {show: true}
                                    }
                                },
                                xAxis: {
                                    type: 'category',
                                    boundaryGap: false,
                                    data:  Config.times
                                },
                                yAxis: {},
                                grid: [{
                                    left: 'left',
                                    top: 'top',
                                    right: '10',
                                    bottom: 30
                                }],
                                series: [{
                                    name:'员工数量',
                                    type: 'line',
                                    smooth: true,
                                    areaStyle: {
                                        normal: {}
                                    },
                                    lineStyle: {
                                        normal: {
                                            width: 1.5
                                        }
                                    },
                                    data:   datas,
                                }]
                            };

                            // 使用刚指定的配置项和数据显示图表。
                            myChart.setOption(option);
                        } else {
                            location.reload();
                        }

                    }
                });
            })

            $("#types-btn2").click(function(){
                var types=$(this).data('info');
                $("#types").val(types)
                var type=$("#c-pid").val()

                $("#types-btn1").removeClass('com-button-click')
                $("#types-btn1").addClass('com-button')
                $("#types-btn2").removeClass('com-button')
                $("#types-btn2").addClass('com-button-click')

                $.ajax({
                    type: 'POST',
                    url: "kupay/paylog/showtypprice",
                    data: {type:type},
                    success: function (info) {
                        if (info.code == 1) {
                            var datas=info.msg
                            var myChart = Echarts.init(document.getElementById('echart'), 'walden');

                            // 指定图表的配置项和数据
                            var option = {
                                title: {
                                    text: '',
                                    subtext: ''
                                },
                                color: [
                                    "#18d1b1",
                                    "#3fb1e3",
                                    "#626c91",
                                    "#a0a7e6",
                                    "#c4ebad",
                                    "#96dee8"
                                ],
                                tooltip: {
                                    trigger: 'axis'
                                },
                                legend: {
                                    data:'实发工资'
                                },
                                toolbox: {
                                    show: false,
                                    feature: {
                                        magicType: {show: true, type: ['stack', 'tiled']},
                                        saveAsImage: {show: true}
                                    }
                                },
                                xAxis: {
                                    type: 'category',
                                    boundaryGap: false,
                                    data:  Config.times
                                },
                                yAxis: {},
                                grid: [{
                                    left: 'left',
                                    top: 'top',
                                    right: '10',
                                    bottom: 30
                                }],
                                series: [{
                                    name:'实发工资',
                                    type: 'line',
                                    smooth: true,
                                    areaStyle: {
                                        normal: {}
                                    },
                                    lineStyle: {
                                        normal: {
                                            width: 1.5
                                        }
                                    },
                                    data:   datas,
                                }]
                            };

                            // 使用刚指定的配置项和数据显示图表。
                            myChart.setOption(option);
                        } else {
                            location.reload();
                        }

                    }
                });
            })
            $("#c-pid").click(function(){
                var type=$(this).val();
                var types=$("#types").val()
                if(types==1){
                    $.ajax({
                        type: 'POST',
                        url: "kupay/paylog/showtypman",
                        data: {type:type},
                        success: function (info) {
                            if (info.code == 1) {
                                var datas=info.msg
                                var myChart = Echarts.init(document.getElementById('echart'), 'walden');

                                // 指定图表的配置项和数据
                                var option = {
                                    title: {
                                        text: '',
                                        subtext: ''
                                    },
                                    color: [
                                        "#18d1b1",
                                        "#3fb1e3",
                                        "#626c91",
                                        "#a0a7e6",
                                        "#c4ebad",
                                        "#96dee8"
                                    ],
                                    tooltip: {
                                        trigger: 'axis'
                                    },
                                    legend: {
                                        data: '员工数量',
                                    },
                                    toolbox: {
                                        show: false,
                                        feature: {
                                            magicType: {show: true, type: ['stack', 'tiled']},
                                            saveAsImage: {show: true}
                                        }
                                    },
                                    xAxis: {
                                        type: 'category',
                                        boundaryGap: false,
                                        data:  Config.times
                                    },
                                    yAxis: {},
                                    grid: [{
                                        left: 'left',
                                        top: 'top',
                                        right: '10',
                                        bottom: 30
                                    }],
                                    series: [{
                                        name:'员工数量',
                                        type: 'line',
                                        smooth: true,
                                        areaStyle: {
                                            normal: {}
                                        },
                                        lineStyle: {
                                            normal: {
                                                width: 1.5
                                            }
                                        },
                                        data:   datas,
                                    }]
                                };

                                // 使用刚指定的配置项和数据显示图表。
                                myChart.setOption(option);
                            } else {
                                location.reload();
                            }

                        }
                    });
                } else{
                    $.ajax({
                        type: 'POST',
                        url: "kupay/paylog/showtypprice",
                        data: {type:type},
                        success: function (info) {
                            if (info.code == 1) {
                                var datas=info.msg
                                var myChart = Echarts.init(document.getElementById('echart'), 'walden');

                                // 指定图表的配置项和数据
                                var option = {
                                    title: {
                                        text: '',
                                        subtext: ''
                                    },
                                    color: [
                                        "#18d1b1",
                                        "#3fb1e3",
                                        "#626c91",
                                        "#a0a7e6",
                                        "#c4ebad",
                                        "#96dee8"
                                    ],
                                    tooltip: {
                                        trigger: 'axis'
                                    },
                                    legend: {
                                        data: '实发工资'
                                    },
                                    toolbox: {
                                        show: false,
                                        feature: {
                                            magicType: {show: true, type: ['stack', 'tiled']},
                                            saveAsImage: {show: true}
                                        }
                                    },
                                    xAxis: {
                                        type: 'category',
                                        boundaryGap: false,
                                        data:  Config.times
                                    },
                                    yAxis: {},
                                    grid: [{
                                        left: 'left',
                                        top: 'top',
                                        right: '10',
                                        bottom: 30
                                    }],
                                    series: [{
                                        name:'实发工资',
                                        type: 'line',
                                        smooth: true,
                                        areaStyle: {
                                            normal: {}
                                        },
                                        lineStyle: {
                                            normal: {
                                                width: 1.5
                                            }
                                        },
                                        data:   datas,
                                    }]
                                };

                                // 使用刚指定的配置项和数据显示图表。
                                myChart.setOption(option);
                            } else {
                                location.reload();
                            }

                        }
                    });
                }
            })
            $(".btn-imgs").click(function(){
                var url='kupay/paylog';
                Backend.api.addtabs(url);
            })

            Controller.api.bindevent();
        },
        type: function () {
            parent.window.$(".layui-layer-iframe").find(".layui-layer-close").on('click',function () {
                parent.location.reload();
            })
            $('.typeadd').click(function () {

                var info = $("#c-name").val()
                if (info == '') {
                    layer.msg('输入框不能为空！');
                    return;
                }
                $.ajax({
                    type: 'POST',
                    url: "kupay/paylog/typesave",
                    data: {name: $("#c-name").val()},
                    success: function (info) {
                        if (info.code == 1) {
                            layer.msg(info.msg)
                            var info = info.data;
                            $(".infos").remove();
                            var html = '';
                            info.forEach(function (element) {
                                html += '<tr class="infos">'
                                    + '<td id="td'+element.id+'" width="60%"><div id="type'+element.id+'">'+element.name+'</div></td>'
                                    + '<td width="40%">'
                                    + '<a href="javascript:;" class="btn  btn-success btn-editone typeedit" data-id="'+element.id+'" data-info="'+element.id+'">编辑</a>'
                                    + '<a href="javascript:;" class="btn  btn-success btn-editone typesave" data-id="'+element.id+'"  id="typeedit'+element.id+'">保存</a>'
                                    + '<a href="javascript:;" class="btn btn-danger btn-del typedel" onclick="typedel()" data-info="'+element.id+'" >删除</a>'
                                    + '</td>'
                                    + '</tr>'
                            });
                            $(".infos").remove()
                            $("#table-type").append(html)
                            $("#c-name").val('')
                        } else {
                            layer.msg(info.msg)
                        }

                    }
                });
            })
            $('body').on('click','.typeedit',function(){
                var id = $(this).data('id')
                //var name=$(this).data('info')
                var div = document.getElementById('type' + id);
                var ipt = document.createElement('input');
                var td = document.getElementById('td' + id);
                var edit = document.getElementById('typeedit' + id);
                ipt.setAttribute('id', 'type' + id);
                ipt.setAttribute('value', div.innerText);
                td.appendChild(ipt);
                div.remove();
                $(this).hide();
                $('#typeedit' + id).show();
            })
            $('body').on('click','.typesave',function(){
                var id = $(this).data('id')
                var info = $("#type" + id).val()
                if (info == '') {
                    layer.msg('输入框不能为空！');
                    return;
                }
                $.ajax({
                    type: 'POST',
                    url: "kupay/paylog/typeupdate",
                    data: {name: info, id: id},
                    success: function (info) {
                        if (info.code == 1) {
                            layer.msg(info.msg)
                            var info = info.data;
                            $(".infos").remove();
                            var html = '';
                            info.forEach(function (element) {
                                html += '<tr class="infos">'
                                    + '<td id="td'+element.id+'" width="60%"><div id="type'+element.id+'">'+element.name+'</div></td>'
                                    + '<td width="40%">'
                                    + '<a href="javascript:;" class="btn  btn-success btn-editone typeedit" data-id="'+element.id+'" data-info="'+element.id+'">编辑</a>'
                                    + '<a href="javascript:;" class="btn  btn-success btn-editone typesave" data-id="'+element.id+'"  id="typeedit'+element.id+'">保存</a>'
                                    + '<a href="javascript:;" class="btn btn-danger btn-del typedel" onclick="typedel()" data-info="'+element.id+'" >删除</a>'
                                    + '</td>'
                                    + '</tr>'
                            });
                            $(".infos").remove()
                            $("#table-type").append(html)
                        } else {
                            layer.msg(info.msg)
                        }

                    }
                });
            })

            $('body').on('click','.typedel',function(){
                var ids = $(this).data('info')
                $.ajax({
                    type: 'POST',
                    url: "kupay/paylog/typedel",
                    data: {ids: ids},
                    success: function (info) {
                        if (info.code == 1) {
                            layer.msg(info.msg)
                            var info = info.data;
                            $(".infos").remove();
                            var html = '';
                            info.forEach(function (element) {
                                html += '<tr class="infos">'
                                    + '<td id="td'+element.id+'" width="60%"><div id="type'+element.id+'">'+element.name+'</div></td>'
                                    + '<td width="40%">'
                                    + '<a href="javascript:;" class="btn  btn-success btn-editone typeedit" data-id="'+element.id+'" data-info="'+element.id+'">编辑</a>'
                                    + '<a href="javascript:;" class="btn  btn-success btn-editone typesave" data-id="'+element.id+'"  id="typeedit'+element.id+'">保存</a>'
                                    + '<a href="javascript:;" class="btn btn-danger btn-del typedel" onclick="typedel()" data-info="'+element.id+'" >删除</a>'
                                    + '</td>'
                                    + '</tr>'
                            });
                            $(".infos").remove()
                            $("#table-type").append(html)
                        } else {
                            layer.msg(info.msg)
                        }

                    }
                });
            });


            Controller.api.bindevent();
        },
        paytypeedit: function () {
            $('.typeedit').click(function () {
                var info = $("#c-name").val()
                if (info == '') {
                    layer.msg('输入框不能为空！');
                    return;
                }
                $.ajax({
                    type: 'POST',
                    url: "kupay/paylog/typeupdate",
                    data: $('form').serialize(),
                    success: function (info) {
                        if (info.code == 1) {
                            layer.msg(info.msg)
                            setTimeout(function () {
                                Fast.api.close();
                            }, 2000);

                        } else {
                            layer.msg(info.msg)
                        }

                    }
                });
            })
            Controller.api.bindevent();
        },
        config: function () {
            $(".btn-primary").click(function () {
                var names = $(this).data('info');
                $.ajax({
                    type: 'POST',
                    url: "kupay/paylog/configsave",
                    data: $('#' + names).serialize(),
                    success: function (info) {
                        if (info.code == 1) {
                            layer.msg(info.msg)

                        } else {
                            layer.msg(info.msg)
                        }

                    }
                });
            })
            Controller.api.bindevent();
        },

        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
